package com.hctforgreen.greenservice.utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

/**
 * 语言设置存储Util
 * 
 * @author denghb
 * 
 */
public class LanguageSettingUtil {

	/**
	 * 保存语言设置
	 * 
	 * @param setting
	 *            0中文版 1英文版
	 * 
	 * @param activity
	 */
	public static void save(Context context, int setting) {
		SharedPreferences sharedPreferences = context.getSharedPreferences(
				HctConstants.LANGUAGE_SETTING_FILE_NAME,
				Context.MODE_WORLD_WRITEABLE);
		Editor editor = sharedPreferences.edit();
		editor.putInt(HctConstants.LANGUAGE_SETTING_KEY_VALUE, setting);
		editor.commit();
	}

	/**
	 * 获取语言设置
	 * 
	 * @param activity
	 * @return language setting 0中文版 1英文版 -1未设置
	 * 
	 */
	public static int get(Context context) {
		SharedPreferences sharedPreferences = context.getSharedPreferences(
				HctConstants.LANGUAGE_SETTING_FILE_NAME,
				Context.MODE_WORLD_WRITEABLE);
		return sharedPreferences.getInt(
				HctConstants.LANGUAGE_SETTING_KEY_VALUE, -1);
	}

}
